package com.gzgy.ustore.api.service.impl;

import com.gzgy.ustore.api.common.Context;
import com.gzgy.ustore.api.dao.UserSessionDao;
import com.gzgy.ustore.api.service.BaseService;
import com.ustore.model.UserSession;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;

@Service
public class BaseServiceImpl extends Context implements BaseService {

	@Autowired
	private UserSessionDao userSessionDao;

	@Override
	public boolean loginCheck(String userId, String sessionId) throws SQLException {
		UserSession userSession = userSessionDao.getSessionByUserId(NumberUtils.toInt(userId),sessionId);
		if(userSession == null) {
			return false;
		}else {
			return  true;
		}
	}

}
